<?php
class Solicitudes_Form_Comite extends Form_Cna {
	
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function init() {
		$domConfig = Zend_Registry::get('domConfig');
		$appConfig = Zend_Registry::get('appConfig');
		
		$this->setName('comite');
		$this->setMethod("post");
		$this->setAttrib('enctype', 'multipart/form-data');
		
		$array_elements[] = new Zend_Form_Element_Hidden("codcomite");
		
        $element = new Zend_Form_Element_MultiCheckbox('tipo');
		$element->setLabel("Tipos de comité para la autoevaluación : ");
		$element->setRegisterInArrayValidator(false);
		$element->clearMultiOptions();
		$element->addMultiOptions($domConfig->TIPOCOMITE->toArray());
	    $element->setRequired(true);
		$element->setOptions(array('onClick'=>'ver_ocultar_tipo(this);'));
		$array_elements[] = $element;
		
		$element = new Zend_Form_Element_Text("nombre");
	    $element->setLabel("Nombre del comité : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;
       
        $element = new Zend_Form_Element_Text('otrotipo');
		$element->setLabel('¿Cual? :');
		$element->addFilter('StringTrim');
		$element->addFilter('StripTags');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("style","display:none");
		$array_elements[] = $element;
        
		$element = new Zend_Form_Element_Text("dependenciacomite");
	    $element->setLabel("Dependencia a la que está adscrito el comité : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;
        		
		$element = new Zend_Form_Element_Text("responsable");
	    $element->setLabel("Nombre del responsable del proceso de autoevaluación : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;

		$element = new Zend_Form_Element_Text("cargo");
	    $element->setLabel("Cargo : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;

        $element = new Zend_Form_Element_Text("dependenciaresponsable");
	    $element->setLabel("Dependencia a la que está adscrito el responsable : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;
        
        $element = new Zend_Form_Element_Text("telefonos");
	    $element->setLabel("Teléfonos (fijo - celular) del responsable : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;
                
        $element = new Zend_Form_Element_Text("correo");
	    $element->setLabel("Correo electrónico del responsable : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
	    $element->addValidator ( 'EmailAddress');
	    $element->setAttribs(array('size'=>50));
        $array_elements[] = $element;
        
		$element = new Zend_Form_Element_Textarea('funciones');
		$element->setLabel('Descripción :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",5);
		$element->setAttrib("style","width:99%");
		$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
		$array_elements[] = $element;
		
		$element = new Zend_Form_Element_File('archivo');
		$element->setLabel('Adjuntar archivo :');
        $element->setMaxFileSize(10485760);
		$element->addValidator('Size', false, 10485760); // 10MB = 10,485,760 bytes
		$element->setDestination($appConfig->get("ruta_archivos"));
//		$element->setDestination($_SERVER['DOCUMENT_ROOT']."/cna/uploads");
        $element->setRequired(false);
        $element->setValueDisabled(true);
        $element->addValidator('Extension', false, $domConfig->EXTENSIONES_ARCHIVOS);
        $element->addValidator('Count', false, 1);
        $array_elements[] = $element;
		
		$element = new Zend_Form_Element_Submit ( 'btnSubmit' );
		$element->setValue('Guardar');
		$element->setLabel("Guardar");
		$element->setAttrib("class", "iceCmdBtn");
		$array_elements[] = $element;
		
		$this->addElements ($array_elements);
		
		$this->loadViewScriptDecorators();
//		$this->loadTableDecorators();
	}
	
	public function loadViewScriptDecorators() {
		$this->setDecorators ( array (array ('viewScript', array ('viewScript' => 'viewscripts/comite_form.phtml' ) ) ) );
	}
}